package com.glorystone.ins.util;

import com.glorystone.ins.enums.inter.EnumInter;
import lombok.extern.slf4j.Slf4j;

/**
 * Created by admin on 2018/4/2.
 */
@Slf4j
public class EnumUtil {
    public static String getEnumDisplay(Integer value,String classPath,String defaultValue){
        try {
            Class<Enum> clazz = (Class<Enum>) Class.forName(classPath);
            Enum[] objs = clazz.getEnumConstants();
            for (Enum obj : objs) {
                EnumInter data = (EnumInter) obj;
                if(value == data.getValue()){
                    return data.getDisplay();
                }
            }
        }catch (ClassNotFoundException e) {
            log.error("获取枚举类型："+classPath+"、值是："+value+"的展示信息异常",e);
        }
        return defaultValue;
    }
}
